<%--
  Created by IntelliJ IDEA.
  User: xiaohuang
  Date: 2021/12/19
  Time: 20:29
  To change this template use File | Settings | File Templates.
--%>
<%@page import="java.sql.*"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
  </head>
  <body>
  <div>
    <%
              //加载驱动
              Class.forName("com.mysql.cj.jdbc.Driver");
               //建立连接
               Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/MyDB", "root",
                             "5201314huang");
               //创建Statement
               Statement stm = (Statement) conn.createStatement();
               //执行查询
               ResultSet rs = stm.executeQuery("select id,name ,pic from movies");
           %>
         <div>
             <%
                 //遍历结果
                 while (rs.next()) {
             %>
             <tr>
                 <td><%=rs.getString(1)%></td>
                 <td><%=rs.getString(2)%></td>
             </tr>
           <img src="<%=rs.getString(3)%>">
             <%
                 }
             %>
         </div>
    37
  </div>
  </body>
</html>
